package hjt.com.module.main.activity;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.tong.lib.base.BaseActivity;

import hjt.com.module.main.R;
import hjt.com.module.main.XiaoMing;
import hjt.com.module.main.databinding.ActivityEmptyBinding;

public class EmptyActivity extends BaseActivity {


    private ActivityEmptyBinding binding;
    private XiaoMing xiaoMing;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_empty;
    }

    @Override
    protected void initDataBinding(int layoutRes) {
        binding = DataBindingUtil.setContentView(this, layoutRes);
        xiaoMing = new XiaoMing();
        xiaoMing.name.set("xiaoming");
        binding.setMing(xiaoMing);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        binding.tvStart1.setOnClickListener(v -> {
            ObjectAnimator.ofFloat(binding.img, "rotationY", 0, 360).setDuration(300).start();
        });

        binding.tvStart2.setOnClickListener(view -> {
            AnimatorSet animatorSet = new AnimatorSet();
            ObjectAnimator rotationX = ObjectAnimator.ofFloat(binding.img, "rotationX", 0, 360);
            ObjectAnimator rotationY = ObjectAnimator.ofFloat(binding.img, "rotationY", 0, 360);
            animatorSet.playTogether(rotationX, rotationY);
            animatorSet.setDuration(300).start();
        });

        binding.tvStart3.setOnClickListener(view -> {
            xiaoMing.url.set("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1583509805&di=2d0acfbee913dc6013e0e3d7cf9ed39a&src=http://h.hiphotos.baidu.com/zhidao/pic/item/0dd7912397dda144dac4acc9b2b7d0a20df486f8.jpg");
            ObjectAnimator.ofFloat(binding.img,"rotation",0,360).setDuration(300).start();
        });
    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected boolean isDataBinding() {
        return true;
    }
}
